package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ZjzxZj;
import com.ruoyi.system.service.IZjzxZjService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专家信息Controller
 * 
 * @author ruoyi
 * @date 2024-10-23
 */
@RestController
@RequestMapping("/system/zj")
public class ZjzxZjController extends BaseController
{
    @Autowired
    private IZjzxZjService zjzxZjService;

    /**
     * 查询专家信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ZjzxZj zjzxZj)
    {
        startPage();
        List<ZjzxZj> list = zjzxZjService.selectZjzxZjList(zjzxZj);
        return getDataTable(list);
    }

    /**
     * 导出专家信息列表
     */
    @Log(title = "专家信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZjzxZj zjzxZj)
    {
        List<ZjzxZj> list = zjzxZjService.selectZjzxZjList(zjzxZj);
        ExcelUtil<ZjzxZj> util = new ExcelUtil<ZjzxZj>(ZjzxZj.class);
        util.exportExcel(response, list, "专家信息数据");
    }

    /**
     * 获取专家信息详细信息
     */
    @GetMapping(value = "/{zhuanjiaId}")
    public AjaxResult getInfo(@PathVariable("zhuanjiaId") Long zhuanjiaId)
    {
        return success(zjzxZjService.selectZjzxZjByZhuanjiaId(zhuanjiaId));
    }

    /**
     * 新增专家信息
     */
    @Log(title = "专家信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZjzxZj zjzxZj)
    {
        if(zjzxZjService.insertZjzxZj(zjzxZj) == 1){
            return success(zjzxZj);
        }
        return toAjax(0);
    }

    /**
     * 修改专家信息
     */
    @Log(title = "专家信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZjzxZj zjzxZj)
    {
        return toAjax(zjzxZjService.updateZjzxZj(zjzxZj));
    }

    /**
     * 删除专家信息
     */
    @Log(title = "专家信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{zhuanjiaIds}")
    public AjaxResult remove(@PathVariable Long[] zhuanjiaIds)
    {
        return toAjax(zjzxZjService.deleteZjzxZjByZhuanjiaIds(zhuanjiaIds));
    }
}
